
        	<?php
        	$form = $this->beginWidget('CActiveForm', array(
        	'action' => $this->createUrl('add'),
        	'method' => 'POST',
        	'id' => 'myForm',
        	'htmlOptions'=>array('target'=>'ajax-frame')
        	));
			?>
            <table>
                <tbody>
                    <tr>
                        <td width="127" align="right" class="pt20 pr3 pb20"><span class="pr5 fontc_orange_red">*</span>学年：</td>
                        <td width="456" class="pt20 pb20">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                                <span class="fl select_shelter select_shelter2">
                                    <select class="fl fontc_666" name="info[exam_term_id]">
                                        <?php if (!empty($info['eduTermData'])): ?>
                                            <?php foreach ($info['eduTermData'] as $ev): ?>
                                                <option
                                                    value="<?php echo $ev['term_start_year']; ?>~<?php echo $ev['term_end_year']; ?>">
                                                    <?php echo $ev['term_start_year']; ?>~<?php echo $ev['term_end_year']; ?>
                                                </option>
                                            <?php endforeach; ?>
                                        <?php endif; ?>
                                    </select>
                                </span>
                            </span>
                        </td>
                    </tr>
                    <tr height="55">
                        <td valign="top" valign="top" align="right" class="pr3"><span class="pr5 fontc_orange_red">*</span>学期：</td>
                        <td valign="top">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                                <span class="fl select_shelter select_shelter2">
                                    <select class="fl fontc_666" name="info[exam_term_sx]" id="exam_term_sx">
                                      <option value="">请选择</option>
                                        <option value="s">第一学期</option>
                                        <option value='x'>第二学期</option>
                                    </select>
                                </span>
                            </span>
                            <div class="fl pt7 pl10">
                                <p id="exam_term_sxTip" ></p>
                            </div>
                        </td>
                    </tr>
                    <tr height="55">
                        <td valign="top" align="right" class="pr3"><span class="pr5 fontc_orange_red">*</span>考试日期：</td>
                        <td valign="top">
                            <div class="clearfix">
                                <input type="text" name="info[exam_start_time]" class="fl w140 pt5 pr5 pb5 pl10 height20 border_c border_3 fontc_666 SipeiTime" value="" id="start_time"  onfocus="var d5222 = $dp.$('end_time');
                                        WdatePicker({dateFmt: 'yyyy-MM-dd ', onpicked: function() {
                                                d5222.focus();
                                            }, maxDate: '#F{$dp.$D(\'end_time\')}'})" />
                                <span class="fl pr5 pl5">至</span>
                                <input type="text" name="info[exam_end_time]" class="fl w140 pt5 pr5 pb5 pl10 height20 border_c border_3 fontc_666 SipeiTime" value="" id="end_time" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd', minDate: '#F{$dp.$D(\'start_time\')}'})" />
                            </div>                            
                            <div class="clearfix">
                                <div class="fl">
                                    <p id="start_timeTip" ></p>
                                </div>
                                <div class="fl">
                                     <p id="end_timeTip" ></p>
                                </div>
                            </div>                            
                        </td>
                    </tr>
                    <tr>
                        <td valign="top" align="right" class="pr3"><span class="pr5 fontc_orange_red">*</span>学段：</td>
                        <td valign="top">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                                <span class="fl select_shelter select_shelter2">
                                    <select class="fl fontc_666" onchange="getGrade(this.value)" name="info[exam_edu_type]" id="exam_edu_type">
                                        <option value="">请选择</option>
                                        <?php if (!empty($info['xdDatas'])): ?>
                                            <?php foreach ($info['xdDatas'] as $xv): ?>
                                                <option value="<?php echo $xv['edu_id']; ?>">
                                                    <?php echo $xv['edu_name']; ?>  
                                                </option>
                                            <?php endforeach; ?>
                                        <?php endif; ?>
                                    </select> 
                                </span> 
                            </span>
                            <div class="fl pt7 pl10">
                                <p id="exam_edu_typeTip" ></p>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td valign="top" align="right" class="pt20 pr3"><span class="pr5 fontc_orange_red">*</span>参加年级：</td>
                        <td valign="top" class="pt20">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3"> 
                                <span class="fl select_shelter select_shelter2" id="gradeSelect"> 
                                    <select class="fl fontc_666" name="info[exam_edu_grade]" id="exam_edu_grade">
                                        <option value="">请选择</option>
                                    </select> 
                                </span> 
                            </span>
                            <div class="fl pt7 pl10">
                                <p id="exam_edu_gradeTip" ></p>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td valign="top" align="right" class="pt20 pr3"><span class="pr5 fontc_orange_red">*</span>项目名称：</td>
                        <td valign="top" class="pt20">
                            <input type="text" name="info[exam_name]" class="fl w100 pt5 pr5 pb5 pl5 height20 border_c border_3 fontc_666" id="exam_name">
                            <div class="fl pt7 pl10">
                                <p id="exam_nameTip" ></p>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td valign="top" align="right" class="pt20 pr3"><span class="pr5 fontc_orange_red">*</span>考试号位数：</td>
                        <td valign="top" class="pt20">
                            <input type="text" name="info[exam_num]" value="" class="fl w100 pt5 pr5 pb5 pl5 height20 border_c border_3 fontc_666" id="exam_num" />
                            <div class="fl pt7 pl10">
                                <p id="exam_numTip" ></p>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td valign="top" align="right" class="pt20 pr3"><span class="pr5 fontc_orange_red">*</span>状态：</td>
                        <td valign="top" class="pt20">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3"> 
                                <span class="fl select_shelter select_shelter2"> 
                                    <select class="fl fontc_666" name="info[exam_status]">
                                        <option value="1">上传数据</option>
                                        <option value="2">阅卷</option>
                                        <option value="0">归档</option>
                                    </select> 
                                </span> 
                            </span>
                        </td>
                    </tr>
                    <tr>
                        <td valign="top" align="right" class="pt15 pr3 height20"><span class="pr5 fontc_orange_red">*</span>参加学校：</td>
                        <td valign="top" class="pt15">
                            <ul>
                                <li class="fl" id="checkSchool">
                                    <h1>请选择学段</h1>
                                </li>
                            </ul>
                             <div class="formValidator_tip">
                                <p id="test33Tip" ></p>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td valign="top" align="right" class="pt15 pr3 height20"><span class="pr5 fontc_orange_red">*</span>参加科目：</td>
                        <td valign="top" class="pt15">
                            <ul id="checkboxSubject" class="clearfix OutList">
                                <?php if (!empty($info['subjectDatas'])): ?>
                                    <?php foreach ($info['subjectDatas'] as $suv): ?>
                                        <li class="fl pr12 pb5">
                                            <input type="checkbox" name="subject[]" value="<?php echo $suv['subject_code']; ?>" /> 
                                            <span class="pl5"> <?php echo $suv['subject_name']; ?></span>
                                        </li>
                                        <?php endforeach; ?>
                                    <?php endif; ?>
                            </ul>
                            <div class="clearfix formValidator_tip">
                                <p id="test2Tip" ></p>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" align="center" class="pt20 pb20">
                            <input type="submit" name="submit"  onclick="return submitCheck()" value="保存" class="b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" />
                        </td>
                    </tr>
                </tbody>
            </table>
	<?php
	$this->endWidget();
	?>


<iframe src='' style="display:none" name='ajax-frame'></iframe>
<script type="text/javascript">
function getGrade(edu_id) {
	$.getJSON("<?php echo $this->createUrl("get_grade"); ?>", {edu_id: edu_id}, function(result) {
		$("#exam_edu_grade").html(result.grade);
		$("#checkSchool").html(result.school);
		if( $("#checkSchool input").length < 1 ){
			$("#checkSchool").parent().next().hide();
		}else{
			$("#checkSchool").parent().next().show();
		}
	});
}
</script>
<script>
function submitCheck(){

	var is_checked = true;
	if($.trim($("#checkboxSubject").html()) == ''){
		$("#test2Tip").html('<p class="noticeWrap"><b class="ico-warning"></b><span class="txt-err">请更新科目信息</span></p>');
		is_checked = false;
	}
	if($.trim($("#checkSchool").html()) == "<h1>请选择学段</h1>"){
		is_checked = false;
	}else{
		var aa = '';
		$("input[name='school[]']:checkbox:checked").each(function(){
			aa+=$(this).val()+',';
		});
		if(aa == ''){

			$("#test33Tip").html('<p class="noticeWrap"><b class="ico-warning"></b><span class="txt-err">至少选择1个</span></p>');
			is_checked = false;
		}else{
			$("#test33Tip").html('<p class="noticeWrap"><b class="ico-succ"></b><span class="txt-succ">已选择</span></p>');
			is_checked = true;
		}
	}
	return is_checked;
}

$(function() {
	if( $("#checkSchool input").length < 1 ){
		$("#checkSchool").parent().next().hide();
	}else{
		$("#checkSchool").parent().next().show();
	}
	function testTime(){
		var msg="";
		if( $("#start_time").val() == "" ){
			msg = "请选择考试开始时间";
		}else if( $("#end_time").val() == "" ){
			msg = "请选择考试结束时间";
		}else{
			msg = true;
		}

		return msg;
	}
	$.formValidator.initConfig({formID: "myForm", theme: "126", submitOnce: false,
	onError: function(msg, obj, errorlist) {
		$("#errorlist").empty();
		$.map(errorlist, function(msg) {
			$("#errorlist").append("<li>" + msg + "</li>");
		});
		//alert(msg);
	}
	});
	/*开始时间验证*/
	$("#start_time").formValidator({
		tipID:"start_timeTip",
		onShowText: "",
		onShow: "",
		onFocus: "",
		onCorrect: "选择正确"
	}).inputValidator({
		min: 1,
		onError: "请选择考试开始日期"
	}).functionValidator({
		fun:testTime
	});
	/*结束时间验证*/
	$("#end_time").formValidator({
		tipID:"start_timeTip",
		onShowText: "",
		onShow: "",
		onFocus: "",
		onCorrect: "选择正确"
	}).inputValidator({
		min: 1,
		onError: "请选择考试结束日期"
	}).functionValidator({
		fun:testTime
	});
	/*学期验证*/
	$("#exam_term_sx").formValidator({
		onShowText: "",
		onShow: "",
		onFocus: "",
		onCorrect: "已选择"
	}).inputValidator({
		min: 1,
		onError: "请选择学期"
	})
	/*学段验证*/
	$("#exam_edu_type").formValidator({
		onShowText: "",
		onShow: "",
		onFocus: "",
		onCorrect: "已选择"
	}).inputValidator({
		min: 1,
		onError: "请选择学段"
	});
	/*参加年级验证*/
	$("#exam_edu_grade").formValidator({
		onShowText: "",
		onShow: "",
		onFocus: "",
		onCorrect: "已选择"
	}).inputValidator({
		min: 1,
		onError: "请选择参加年级"
	});
	/*名称验证*/
	$("#exam_name").formValidator({
		onShowText: "请输入项目名称",
		onShow: "",
		onFocus: "",
		onCorrect: "输入正确",
		leftTrim:true,
		rightTrim:true
	}).inputValidator({
		min: 1,
		max:100,
		onError: "项目名称长度在1-100之间(1-50个汉字)"
	});

	/*考试号位数验证*/
	$("#exam_num").formValidator({
		onShowText: "请输入考号位数",
		onShow: "",
		onFocus: "",
		onCorrect: "输入正确",
		leftTrim:true,
		rightTrim:true
	}).inputValidator({
		min: 1,
		max:3,
		onError: "考试号位数长度在1-3之间"
	}).regexValidator({
		regExp: "intege1",
		dataType: "enum",
		onError: "考号位数必须是正整数"
	});

	$(":checkbox[name='subject[]']").formValidator({
		tipID:"test2Tip",
		onShow:"",
		onFocus:"至少选择1个",
		onCorrect:"选择正确",
		defaultValue:["7","8"]
	}).inputValidator({
		min:1,
		onError:"至少选择1个"
	});

})
</script>
<?php exit;?>